BASE64-kodiertes Pony anzeigen
In diesem Beispielprogramm zeige ich dir, wie du ein niedliches Pony anzeigen kannst. Grüße gehen raus an Marco Matjes. Das Coding ist nicht schön, aber es zeigt, wie man ein BASE64-Codiertes Bild (in diesem Fall ein GIF) in einem Container anzeigen kann. Kleine Bilder oder Icons können so relativ einfach im Quelltext eingebunden werden.
Code
REPORT.
DATA picture TYPE REF TO cl_gui_picture.
DATA pic_container TYPE REF TO cl_gui_docking_container.
DATA graphic_url(255).
TYPES: BEGIN OF graphic_str,
line(255) TYPE x,
END OF graphic_str,
graphic_tab TYPE STANDARD TABLE OF graphic_str.
DATA graphic_table TYPE graphic_tab.
DATA graphic_size TYPE i.
PARAMETERS p_dummy.
INITIALIZATION.
PERFORM show.
START-OF-SELECTION.
DEFINE a.
concatenate l_graphic_str &1 into l_graphic_str.
END-OF-DEFINITION.
FORM show.
DATA: l_graphic_xstr TYPE xstring,
l_graphic_x TYPE x,
l_graphic_conv TYPE i,
l_graphic_str TYPE string,
l_graphic_offs TYPE i.
pic_container = NEW #( extension = 300 no_autodef_progid_dynnr = 'X' ).
picture = NEW #( parent = pic_container ).
CLEAR graphic_table.
"GIF rennpony 16 colors
a 'R0lGODlhFQATADMAACH5BAAAAAAALAAAAAAVABMAg////19qcHaPjo6ij5XL/p3Mx6rR3qTS+LPUksPessjcysvl+ufbrvrclPfv1Or'.
a '0+wSMEMg5F1mY6g0eztzmNA3TKEu4LYaptI2jShbBMIahlDNwXCwDYcdQeQ6HwEDxOyiKmyNhKhj8pobYBjkl6K5TokZRKBe+3enhRn'.
a 'Eg3u/EbwH2aiWJfB6hfjzAa3d6ewYHDzRpWQ0SCoMJBoc0gCYOMo15hho1aiaLAAqgkRR/aYE9iKVQPZtppwCsXREAOw=='.
CALL FUNCTION 'SSFC_BASE64_DECODE'
EXPORTING
b64data = l_graphic_str
IMPORTING
bindata = l_graphic_xstr
EXCEPTIONS
OTHERS = 8.
graphic_size = xstrlen( l_graphic_xstr ).
CHECK graphic_size > 0.
l_graphic_conv = graphic_size.
l_graphic_offs = 0.
WHILE l_graphic_conv > 255.
APPEND VALUE #( line = l_graphic_xstr+l_graphic_offs(255) ) TO graphic_table.
l_graphic_offs = l_graphic_offs + 255.
l_graphic_conv = l_graphic_conv - 255.
ENDWHILE.
APPEND VALUE #( line = l_graphic_xstr+l_graphic_offs(l_graphic_conv) ) TO graphic_table.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image' "#EC NOTEXT
subtype = 'gif'
cacheable = space
size = graphic_size
lifetime = cndp_lifetime_transaction
TABLES
data = graphic_table
CHANGING
url = graphic_url.
picture->clear_picture( ).
picture->load_picture_from_url( url = graphic_url ).
picture->set_display_mode( cl_gui_picture=>display_mode_fit ).
ENDFORM.
Letzte Artikel von Enno Wulff (Alle anzeigen)
- Meine Eclipse-Plugins - 22. November 2024
- Interview mit Björn Schulz (Software-Heroes.com) - 3. September 2024
- Daten aus ALV ermitteln - 3. September 2024